//
//  CoreDateManager.h
//  SQLiteTest
//
//  Created by rhljiayou on 14-1-8.
//  Copyright (c) 2014年 rhljiayou. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>
#import "BPProductDetail.h"
#import "BPAddressModel.h"
#import "HomeModel.h"

@interface CoreDateManager : NSObject

@property (readonly, strong, nonatomic) NSManagedObjectContext *managedObjectContext;
@property (readonly, strong, nonatomic) NSManagedObjectModel *managedObjectModel;
@property (readonly, strong, nonatomic) NSPersistentStoreCoordinator *persistentStoreCoordinator;

- (void)saveContext;
- (NSURL *)applicationDocumentsDirectory;

/**插入home数据*/
- (void)insertCoreData:(NSArray *)productsModel;
/**查询所有home数据*/
- (NSMutableArray *)homeData;
/**删除所有home数据*/
- (void)deleteData;
/**插入list数据*/
- (void)insertProductListData:(NSArray *)modelArry addCID:(NSString *)cid;
/**查询list数据*/
- (NSMutableArray *)productListaddCID:(NSString *)cid;
/**删除一类list*/
- (void)deleteProductListaddCID:(NSString *)cid;

/**插入产品详情信息*/
- (void)insertProductDetail:(BPProductDetail *)productdetailModel;
/**查询产品详情并返回信息*/
- (BPProductDetail *)returnProductDetail:(NSString*)productID;
/**删除产品信息*/
- (void)deleteProductDetail:(NSString *)productID;


/**批量插入收货地址*/
- (void)insertAddress:(NSArray *)addressArry;
/**删除收货地址*/
- (void)deleteAddress:(NSString *)uid;

/**更新一个地址*/
- (void)updateAddressWithAddress:(BPAddressModel *)addressMdel;

/**添加一个地址*/
- (void)insertOneAddress:(BPAddressModel *)model;
/**删除一个地址*/
- (void)deleteOneAddress:(BPAddressModel *)model;

/**获取一个用户所有地址*/
- (NSMutableArray *)addressAllData:(NSString *)uid;
/**获取默认收获地址*/
- (BPAddressModel *)getDefaultAddressWithuid:(NSString *)uid;
/**设置默认收获地址*/
- (void)updateDefaultAddress:(int)newDefault lastAddress:(int)lastID withuid:(NSString *)uid;

/**插入一条作品信息*/
- (void)saveADIYproduct:(BPProductDetail *)Myproduct;
/**更新一条作品信息*/
- (void)updateADIYproduct:(BPProductDetail *)Myproduct;
/**删除一条作品*/
- (void)removeOneProduct:(NSString *)makeDate withUID:(NSString *)uid;

- (void)deletOneProduct:(NSString *)workID;
/**获取一个用户所有作品信息*/
- (NSMutableArray *)allMyProducts:(NSString *)uid;

- (BPProductDetail *)getOneMyProduct:(NSString *)workID;

- (BPProductDetail *)haveProduct:(NSString *)workID;

/**插入要上传的数据*/
- (void)insertUnpostImage:(NSArray *)postArry;

/**删除已上传的数据*/
- (void)deleteUnpostInfo:(NSString *)imageKey;
- (void)deleteAllpost;
/**获取所有未上传的数据*/
- (NSMutableArray *)getAllunpostArry;

@end
